import { Component, type ReactNode } from "react";

interface IProps {
  title: string;
  children?: ReactNode;
  onClose: () => void;
}

export default class Modal extends Component<IProps> {
  render() {
    return (
      <div className="modal">
        <div className="modal__mask"></div>
        <div className="modal__container">
          <div className="modal-header">
            <div className="modal-title">{this.props.title}</div>
            <div className="modal-close">
              <button onClick={this.props.onClose}>x</button>
            </div>
          </div>
          <div className="modal-body">
            {this.props.children ? this.props.children : <p>默认内容</p>}
          </div>
        </div>
      </div>
    );
  }
}
